package com.zmzncs.lmtc.module.park.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zmzncs.lmtc.common.pojo.PageInfo;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.park.pojo.park_info.ParkInfoDTO;
import com.zmzncs.lmtc.module.park.pojo.park_info.ParkInfoListForm;
import com.zmzncs.lmtc.module.park.pojo.park_info.ParkTableVO;
import com.zmzncs.lmtc.module.park.pojo.park_manager.ParkManagerDTO;
import com.zmzncs.lmtc.module.park.pojo.park_manager.ParkManagerSearchForm;
import com.zmzncs.lmtc.module.park.pojo.reserve_record.ReserveRecordDTO;
import com.zmzncs.lmtc.module.park.pojo.reserve_record.ReserveRecordInfoVO;
import com.zmzncs.lmtc.module.park.pojo.reserve_record.ReserveRecordManageForm;
import com.zmzncs.lmtc.module.park.pojo.reserve_record.ReserveRecordTableVO;
import com.zmzncs.lmtc.module.park.service.ReserveRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 预约记录表 前端控制器
 * </p>
 *
 * @author 高博文
 * @since 2020-12-15
 */
@Api(tags = {"预约记录"})
@RestController
@RequestMapping("/park/reserve-record")
public class ReserveRecordController {

    @Autowired
    ReserveRecordService reserveRecordService;

    @ApiOperation(value = "获取预约记录分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @PostMapping(value = "/reserveRecordPage")
    public Rest<PageInfo<ReserveRecordTableVO>> reserveRecordPage(@RequestBody ReserveRecordManageForm form){
        IPage<ReserveRecordDTO> reserveRecordPage = reserveRecordService.reserveRecordPage(form);
        PageInfo<ReserveRecordTableVO> recordTableVOPageInfo = JsonUtil.pageTransform(reserveRecordPage, ReserveRecordTableVO.class);

        return RestUtil.success(recordTableVOPageInfo);
    }

    @ApiOperation(value = "预约记录详情")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(name = "id", value = "预约记录ID", required = true),
    })
    @PostMapping(value = "/getReserveRecordById")
    public Rest<ReserveRecordInfoVO> getReserveRecordById(@NotNull Long id){
        ReserveRecordInfoVO reserveRecordInfoVO = reserveRecordService.getReserveRecordById(id);

        return RestUtil.success(reserveRecordInfoVO);
    }


}

